package nakedb;

import java.awt.Color;

import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;


/**
 * Statistic panel of NakeDB.
 */
public class StatisticsPanel extends JPanel {
	static JLabel nodeInfoLabel;
	JLabel numberOfNodesLabel, numberOfConnectionsLabel;
	JLabel numberOfNodes, numberOfConnections;
	JPanel generalInfoPanel, nodeInfoPanel;
	
	public StatisticsPanel(NakeDB nakedb){
		this.setLayout(null);
		
		
		generalInfoPanel = new JPanel();
		generalInfoPanel.setBorder(BorderFactory.createTitledBorder("General"));
		generalInfoPanel.setBackground(Color.white);
		generalInfoPanel.setSize(310, 120);
		generalInfoPanel.setLocation(0, 0);
		generalInfoPanel.setVisible(true);

		numberOfNodesLabel = new JLabel("Total Number of Tables: ");
		numberOfNodes = new JLabel(nakedb.getTotalNumberOfTables()+"\n");
		numberOfConnectionsLabel = new JLabel("Total Number of Relations: ");
		numberOfConnections = new JLabel(nakedb.getTotalNumberOfConnections()+"\n");
		
		
		generalInfoPanel.add(numberOfNodesLabel);
		generalInfoPanel.add(numberOfNodes);
		generalInfoPanel.add(numberOfConnectionsLabel);
		generalInfoPanel.add(numberOfConnections);
		
		nodeInfoPanel = new JPanel();
		nodeInfoPanel.setBorder(BorderFactory.createTitledBorder("Node Info"));
		nodeInfoPanel.setBackground(Color.white);
		nodeInfoPanel.setSize(310, 300);
		nodeInfoPanel.setLocation(0, 120);
		nodeInfoPanel.setVisible(true);
		
		nodeInfoLabel = new JLabel("Select a node to display info");
		
		nodeInfoPanel.add(nodeInfoLabel);
		
		this.add(generalInfoPanel);
		this.add(nodeInfoPanel);
		setBackground(Color.white);
		setSize(310, 680);
		setVisible(true);
	}
	
	public static void setInfo(StringBuffer s){
		nodeInfoLabel.setText(s.toString());
	}
}
